<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
  <head>
    <title>雪花钢城内购价报名表</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,uer-scalable=no">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.1.1/css/bootstrap.min.css">
  </head>
  <body>
  
    <div class="container">
    
    <img src="http://static.hutiao.me/snow/huodong/wugangsignup.jpg" class="img-responsive">
    
    <h3><span class="label label-default">在线报名</span></h3>
    
    <s:form id="wugangform" action="wugangtuangou" theme="simple" role="form">
    
	  <div class="form-group">
	    <label for="inputName">姓名</label>
	    <s:textfield key="bean.name" data-toggle="tooltip" cssClass="form-control" id="inputName" placeholder="" />
	  </div>
      <div class="form-group">
	    <label for="inputPhone">电话</label>
	    <s:textfield key="bean.phone" data-toggle="tooltip" cssClass="form-control" id="inputPhone" placeholder="" />
	  </div>
	  <div class="form-group">
	    <label for="inputPackage0" class="">购酒种类</label>
	    <s:select list="{'---请选择套餐---','A套餐：仅购买雪花勇闯天涯','B套餐：仅购买雪花纯生','C套餐：雪花勇闯天涯和雪花纯生都购买'}" theme="simple" name="bean.package0" id="inputPackage0" cssClass="form-control"></s:select>
	  </div>
	  <div class="form-group">
	    <label for="inputAmount">购买箱数</label>
	    <s:textfield key="bean.amount" data-toggle="tooltip" cssClass="form-control" id="inputAmount" placeholder="" />
	  </div>
      <p class="text-danger">亲，如果购买C套餐，请在购买箱数里标明：勇闯*箱，纯生*箱，每人限购10箱哦～</p>
      <s:submit id="saveForm" value="提交" data-loading-text="正在保存..." cssClass="btn btn-primary btn-lg btn-block" />
    </s:form>
    
    </div>
    
    
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <script src="../js/jquery.form.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
    
    <script type="text/javascript">
    
    $(document).ready(function(){
    	$("form").submit(function(e){
    		
    		var name = $('#inputName').val();
    		var phone = $('#inputPhone').val();
    		var package0 = $('#inputPackage0').val();
    		var amount = $('#inputAmount').val();
    		if (name==null || name=='') {
    			alert("请填写姓名");
    			return;
    		}
    		if (phone==null || phone=='') {
    			alert("请填写电话");
    			return;
    		}
    		if (package0==null || package0=='' || package0=='---请选择套餐---' ) {
    			alert("请选择购酒种类");
    			return;
    		}
    		if (amount==null || amount=='') {
    			alert("请填写购买箱数");
    			return;
    		}

    		var params=$('#wugangform').formSerialize();
    		params = decodeURIComponent(params,true);
    		$.ajax({
    			type: "POST",
				url: "./wugangtuangou_save",
				dataType: "json",
				data: params,
				async: false,
				success: function(data) {
					alert(data.result);
				},
				error: function(err) {
					alert("抱歉，我们遇到一点问题，请稍后再试。");
				}
			});
    		
    		
    	});
    });
    
    </script>
    
  </body>
</html>
